<template>
  <div>
    <!-- 下拉样式 -->
    <template v-if="styleVal == 1">
      <el-dropdown v-if="
        dropdownMenuList.length ||
        (dataObj.status == 1090 && UserInfo.position_id == 7) ||
        ((dataObj.status == 1118 || dataObj.status == 1120) &&
          UserInfo.position_id == 8) ||
        (dataObj.status == 1095 && UserInfo.position_id == 2) ||
        (dataObj.status == 1140 && UserInfo.position_id == 2) ||
        (dataObj.status < 1150 && userInfoData.position_id == 2)
      " @command="commandFunc">
        <span class="el-dropdown-link">
          <el-button type="text">操作</el-button>
          <i class="el-icon-arrow-down el-icon--right" style="color: #3d7fff"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item v-for="(item, index) in dropdownMenuList" :key="index" :command="item.state">{{ item.label
            }}</el-dropdown-item>
          <el-dropdown-item v-if="dataObj.status == 1095 && UserInfo.position_id == 2"
            @click.native="xmhtFunc('bj')">回退至项目报价单</el-dropdown-item>
          <el-dropdown-item v-if="dataObj.status == 1090 && UserInfo.position_id == 7"
            @click.native="gcjljjjdVisible = true">拒绝接单</el-dropdown-item>
          <el-dropdown-item v-if="
            (dataObj.status == 1118 || dataObj.status == 1120) &&
            UserInfo.position_id == 8
          " @click.native="sgjlFunc">施工记录</el-dropdown-item>
          <el-dropdown-item v-if="dataObj.status == 1140 && UserInfo.position_id == 2"
            @click.native="xmhtFunc('js')">回退至项目结算单</el-dropdown-item>
          <template v-if="dataObj.status < 1150 && userInfoData.position_id == 2">
            <el-dropdown-item @click.native="dkrzVisible = true">对客日志</el-dropdown-item>
            <el-dropdown-item @click.native="editProjectFunc">项目完善</el-dropdown-item>
            <el-dropdown-item @click.native="xmhtFunc('js')">项目取消</el-dropdown-item>
          </template>
        </el-dropdown-menu>
      </el-dropdown>
      <span v-else>--</span></template>
    <!-- 按钮样式 -->
    <template v-if="styleVal == 2">
      <el-button @click="commandFunc(item.state)" type="primary" v-for="(item, index) in dropdownMenuList"
        :key="index">{{ item.label }}</el-button>
      <el-button v-if="dataObj.status == 1095 && UserInfo.position_id == 2" @click.native="xmhtFunc('bj')"
        type="primary">回退至项目报价单</el-button>
      <el-button v-if="dataObj.status == 1090 && UserInfo.position_id == 7"
        @click.native="gcjljjjdVisible = true">拒绝接单</el-button>
      <el-button v-if="
        (dataObj.status == 1118 || dataObj.status == 1120) &&
        UserInfo.position_id == 8
      " @click.native="xmhtFunc('bj')" type="primary">施工记录</el-button>
      <el-button v-if="dataObj.status == 1140 && UserInfo.position_id == 2" @click.native="xmhtFunc('js')"
        type="primary">回退至项目结算单</el-button>
      <template v-if="dataObj.status < 1150 && userInfoData.position_id == 2">
        <el-button @click.native="dkrzVisible = true" type="primary">对客日志</el-button>
        <el-button @click.native="editProjectFunc" type="primary">项目完善</el-button>
        <el-button @click.native="xmhtFunc('js')">项目取消</el-button>
      </template>
    </template>
    <!-- 分配客户经理 -->
    <fpkhjlCom :project_id="dataObj.id" :addDialogVisible="fpkhjlVisible" @onClose="fpkhjlVisible = false"
      @onSuccess="onSuccess"></fpkhjlCom>
    <!-- 分配工程经理 -->
    <fpgcjCom :project_id="dataObj.id" :detailData="dataObj" :addDialogVisible="fpgcjVisible"
      @onClose="fpgcjVisible = false" @onSuccess="onSuccess"></fpgcjCom>
    <!-- 分配造价员 -->
    <fpzjyCom :project_id="dataObj.id" :addDialogVisible="fpzjyVisible" @onClose="fpzjyVisible = false"
      @onSuccess="onSuccess"></fpzjyCom>
    <!-- 工程经理拒绝接单 -->
    <gcjljjjdCom :project_id="dataObj.id" :addDialogVisible="gcjljjjdVisible" @onClose="gcjljjjdVisible = false"
      @onSuccess="onSuccess"></gcjljjjdCom>
    <!-- 确认增减项 -->
    <qrzjxCom :project_id="dataObj.id" :addDialogVisible="qrzjxVisible" @onClose="qrzjxVisible = false"
      @onSuccess="onSuccess"></qrzjxCom>
    <!-- 对客日志 -->
    <dkrzCom :project_id="dataObj.id" :addDialogVisible="dkrzVisible" @onClose="dkrzVisible = false"
      @onSuccess="onSuccess">
    </dkrzCom>
    <!-- 完善项目 -->
    <addProjectCom :addData="addFormInline" :addDialogVisible="addDialogVisible" @cancelFunc="cancelFunc"
      @addProjectSuccess="onSuccess" :detailData="dataObj" :surveySiteDisabled="surveySiteDisabled"></addProjectCom>
  </div>
</template>
<script>
import { getUserInfo } from "@/utils/auth";
import projectApi from "@/api/projectApi";
import addProjectCom from "@/components/addProjectCom/index";
import fpkhjlCom from "@/components/projectPopu/fpkhjlCom/index";
import scsjtCom from "@/components/projectPopu/scsjtCom/index";
import dkrzCom from "@/components/projectPopu/dkrzCom/index";
import fpgcjCom from "@/components/projectPopu/fpgcjCom/index";
import tjkcxxCom from "@/components/projectPopu/tjkcxxCom/index";
import shkczlCom from "@/components/projectPopu/shkczlCom/index";
import sqbjCom from "@/components/projectPopu/sqbjCom/index";
import fpzjyCom from "@/components/projectPopu/fpzjyCom/index";
import cjzjdCom from "@/components/projectPopu/cjzjdCom/index";
import shbjdCom from "@/components/projectPopu/shbjdCom/index";
import dkbjCom from "@/components/projectPopu/dkbjCom/index";
import shdkbjdCom from "@/components/projectPopu/shdkbjdCom/index";
import tjqdhtCom from "@/components/projectPopu/tjqdhtCom/index";
import tjyfkpzCom from "@/components/projectPopu/tjyfkpzCom/index";
import yfkdkqrCom from "@/components/projectPopu/yfkdkqrCom/index";
import qrkssgCom from "@/components/projectPopu/qrkssgCom/index";
import jdysCom from "@/components/projectPopu/jdysCom/index";
import jdysshCom from "@/components/projectPopu/jdysshCom/index";
import tjjdkpzCom from "@/components/projectPopu/tjjdkpzCom/index";
import jdkqrCom from "@/components/projectPopu/jdkqrCom/index";
import qrzjxCom from "@/components/projectPopu/qrzjxCom/index";
import gcjljjjdCom from "@/components/projectPopu/gcjljjjdCom/index";
import xmqxCom from "@/components/projectPopu/xmqxCom/index";
import sgjlCom from "@/components/projectPopu/sgjlCom/index";
import cjjsdCom from "@/components/projectPopu/cjjsdCom/index";
import projectLogCom from "@/components/projectPopu/projectLogCom/index";
import shjsdCom from "@/components/projectPopu/shjsdCom/index";
import tjwkpzCom from "@/components/projectPopu/tjwkpzCom/index";
import qrwkxxCom from "@/components/projectPopu/qrwkxxCom/index";
import style from "tinymce-imageupload/css/style";
import idiInfo from "@/components/increaseDecreaseItemsInfo";
import asInfo from "@/components/afterSales";
import shwkxxCom from "@/components/projectPopu/shwkxxCom/index";
export default {
  name: "",
  components: {
    asInfo,
    idiInfo,
    addProjectCom,
    fpkhjlCom,
    scsjtCom,
    dkrzCom,
    fpgcjCom,
    tjkcxxCom,
    shkczlCom,
    sqbjCom,
    fpzjyCom,
    cjzjdCom,
    shbjdCom,
    dkbjCom,
    shdkbjdCom,
    tjqdhtCom,
    tjyfkpzCom,
    yfkdkqrCom,
    qrkssgCom,
    jdysCom,
    jdysshCom,
    tjjdkpzCom,
    jdkqrCom,
    qrzjxCom,
    gcjljjjdCom,
    xmqxCom,
    sgjlCom,
    cjjsdCom,
    projectLogCom,
    shjsdCom,
    tjwkpzCom,
    qrwkxxCom,
    shwkxxCom,
  },
  props: {
    dataObj: {
      default: "",
      required: false,
    },
    styleVal: {
      default: 2,
    },
  },
  data() {
    return {
      menuList: [
        {
          state: 1000,
          label: "分配客户经理",
          id: 1,
        },
        {
          state: 1010,
          label: "选择勘场",
          id: 2,
        },
        {
          state: 1015,
          label: "上传设计图",
          id: 2,
        },
        {
          state: 1020,
          label: "提交勘场凭证",
          id: 2,
        },
        {
          state: 1025,
          label: "勘场费打款确认",
          id: 9,
        },
        {
          state: 1030,
          label: "分配勘场工程经理",
          id: 6,
        },
        {
          state: 1045,
          label: "提交勘场报告",
          id: 7,
        },
        {
          state: 1055,
          label: "上传勘场资料",
          id: 3,
        },
        {
          state: 1060,
          label: "上传设计图",
          id: 2,
        },
        {
          state: 1065,
          label: "申请报价",
          id: 2,
        },
        {
          state: 1070,
          label: "分配造价员",
          id: 4,
        },
        {
          state: 1070,
          label: "分配施工工程经理",
          id: 6,
        },
        {
          state: 1080,
          label: "分配施工工程经理",
          id: 6,
        },
        {
          state: 1090,
          label: "分配施工工程经理",
          id: 6,
        },
        {
          state: 1080,
          label: "出具造价单",
          id: 5,
        },
        {
          state: 1090,
          label: "审核造价单",
          id: 7,
        },
        // {
        //   state: 1090,
        //   label: "拒绝接单",
        //   id: 7,
        // },
        {
          state: 1092,
          label: "审核造价单",
          id: 4,
        },
        {
          state: 1095,
          label: "对客报价",
          id: 2,
        },
        {
          state: 1100,
          label: "审核对客报价单",
          id: 1,
        },
        {
          state: 1102,
          label: "提交签订合约",
          id: 2,
        },
        {
          state: 1105,
          label: "提交预付款凭证",
          id: 2,
        },
        {
          state: 1110,
          label: "预付款打款确认",
          id: 9,
        },
        {
          state: 1115,
          label: "确认开始施工",
          id: 8,
        },
        {
          state: 1118,
          label: "节点验收",
          id: 7,
          node_status: 1,
          engineering_manager_id: "",
        },
        {
          state: 1120,
          label: "节点验收",
          id: 7,
          node_status: 1,
          engineering_manager_id: "",
        },
        {
          state: 1120,
          label: "节点验收审核",
          id: 8,
          node_status: 2,
        },
        {
          state: 1120,
          label: "节点验收审核",
          id: 6,
          node_status: 3,
        },
        {
          state: 1120,
          label: "提交进度款凭证",
          id: 2,
          node_status: 4,
        },
        {
          state: 1120,
          label: "进度款打款确认",
          id: 9,
          node_status: 5,
        },
        // {
        //   state: 1118,
        //   label: "施工记录",
        //   id: 8,
        // },
        // {
        //   state: 1120,
        //   label: "施工记录",
        //   id: 8,
        // },
        {
          state: 1125,
          label: "确认增减项",
          id: 2,
        },
        {
          state: 1130,
          label: "出具结算单",
          id: 5,
        },
        {
          state: 1135,
          label: "审核结算单",
          id: 7,
        },
        {
          state: 1138,
          label: "审核结算单",
          id: 4,
        },
        {
          state: 1140,
          label: "提交尾款信息",
          id: 2,
        },
        // {
        //   state: 1140,
        //   label: "回退至项目结算单",
        //   id: 2,
        // },
        {
          state: 1145,
          label: "审核尾款信息",
          id: 1,
        },
        {
          state: 1147,
          label: "确认尾款信息",
          id: 9,
        },
        {
          state: 1500,
          label: "删除项目",
          id: 10,
        },
      ],
      // 完善项目d
      addFormInline: {
        designer_name: "",
        project_id: "",
        channel_manager_id: "",
        channel_manager_name: "",
        project_type: "",
        project_name: "",
        project_city: [],
        address: "",
        user_id: "",
        channel_manager_id: "",
        brand_id: "",
        survey_site: "",
        designer_id: "",
        template_id: "",
        // engineeringSupervision_id: '',
        survey_date: "",
      },
      dropdownMenuList: [],
      projectNodesItem: "",
      fieldList: [],
      shkxpzData: {},
      // 分配客户经理
      fpkhjlVisible: false,
      //收款账户列表
      companyList: [],
      diaLoading: false,
      // 分配工程经理
      fpgcjVisible: false,
      // 提交勘场报告
      tjkcxxVisible: false,
      // 上传勘场资料
      shkczlVisible: false,
      // 用户信息
      userInfoData: {},
      // 对客日志提交
      dkrzVisible: false,
      // 上传设计图
      scsjtVisible: false,
      // 申请报价
      sqbjVisible: false,
      // 分配造价员
      fpzjyVisible: false,
      // 工程经理拒绝接单
      gcjljjjdVisible: false,
      // 出具造价单
      cjzjdVisible: false,
      // 审核造价单
      shbjdVisible: false,
      // 对客报价
      dkbjVisible: false,
      // 取消项目
      xmqxVisible: false,
      // 审核对客报价单
      shdkbjdVisible: false,
      // 签订合同
      tjqdhtVisible: false,
      // 提交预付款凭证
      tjyfkpzVisible: false,
      // 预付款确认
      yfkdkqrVisible: false,
      // 开始施工确认
      qrkssgVisible: false,
      // 节点验收审核
      jdysshVisible: false,
      // 提交进度款凭证
      tjjdkpzVisible: false,
      // 进度款凭证确认
      jdkqrVisible: false,
      // 施工日志
      sgjlVisible: false,
      // 确认增减项
      qrzjxVisible: false,
      // 出具结算单
      cjjsdVisible: false,
      // 审核结算单
      shjsdVisible: false,
      // 提交尾款凭证
      tjwkpzVisible: false,
      // 审核尾款信息
      shwkxxVisible: false,
      // 确认尾款信息
      qrwkxxVisible: false,
      // 完善项目
      addDialogVisible: false,
      UserInfo: "",
      surveySiteDisabled: false,
    };
  },
  watch: {
    dataObj() {
      console.log(this.dataObj, "this.dataObj")
      if (this.dataObj) {
        this.UserInfo = getUserInfo();
        this.getProjectDetails();
      }
    },
  },
  computed: {},
  mounted() {
      if (this.dataObj) {
        this.UserInfo = getUserInfo();
        this.getProjectDetails();
      }
  },
  methods: {
    // 点击按钮
    commandFunc(e) {
      console.log(e);
      let { position_id, userid } = getUserInfo();
      // this.getProjectLogNew(e);
      switch (e) {
        case 1000: //分配客户经理
          this.fpkhjlVisible = true;
          break;
        case 1010: //选择勘场
          break;
        case 1015: //上传设计图
          break;
        case 1020: //提交勘场凭证
          this.$router.push({
            path: "/kcxx",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1025: //勘场费打款确认
          this.$router.push({
            path: "/kcfdkqr",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1030: //分配勘场工程经理
          this.fpgcjVisible = true;
          break;
        case 1045: //提交勘场报告
          this.$router.push({
            path: "/tjkcxx",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1055: //上传勘场资料
          this.$router.push({
            path: "/shkczl",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1060: //上传设计图
          this.$router.push({
            path: "/scsjt",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1065: //申请报价
          this.$router.push({
            path: "/sqbj",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1070:
          //------------分配造价员-------------
          if (position_id == 4) {
            this.fpzjyVisible = true;
          }
          //----------------分配施工工程经理--------------------
          if (position_id == 6) {
            this.fpgcjVisible = true;
          }
          break;
        case 1080:
          //-------------------分配施工工程经理--------------------
          if (position_id == 6) {
            this.fpgcjVisible = true;
          }
          //----------------出具造价单----------------
          if (position_id == 5) {
            this.$router.push({
              path: "/cjzjd",
              query: {
                id: this.dataObj.id,
              },
            });
          }
          break;
        case 1090:
          //---------------分配施工工程经理--------------------
          if (position_id == 6) {
            this.fpgcjVisible = true;
          }
          // -----------------审核造价单-------------------
          if (position_id == 7) {
            this.$router.push({
              path: "/shbjd",
              query: {
                id: this.dataObj.id,
              },
            });
          }
          // -----------------施工工程经理拒绝接单-------------------
          // if (position_id == 7) {
          //   this.gcjljjjdVisible = true;
          // }
          break;
        case 1092: //审核造价单
          this.$router.push({
            path: "/shbjd",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1095: //对客报价
          this.$router.push({
            path: "/dkbj",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1100: //审核对客报价单
          this.$router.push({
            path: "/shdkbjd",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1102: //提交签订合约
          this.$router.push({
            path: "/tjqdht",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1105: //提交预付款凭证
          this.$router.push({
            path: "/tjyfkpz",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1110: //预付款打款确认
          this.$router.push({
            path: "/yfkdkqrCom",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1115: //确认开始施工
          this.$router.push({
            path: "/qrkssg",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1118:
          //-------------节点验收----------------
          if (position_id == 7) {
            this.$router.push({
              path: "/jdys",
              query: {
                id: this.dataObj.id,
              },
            });
          }
          //-------------施工记录----------------
          // if (position_id == 8) {
          //   this.$router.push({
          //     path: "/sgjl",
          //     query: {
          //       id: this.dataObj.id,
          //     },
          //   });
          // }
          break;
        case 1120:
          //-------------节点验收----------------
          if (position_id == 7) {
            this.$router.push({
              path: "/jdys",
              query: {
                id: this.dataObj.id,
              },
            });
          }
          //-------------节点验收审核----------------
          if (position_id == 8) {
            this.$router.push({
              path: "/jdyssh",
              query: {
                id: this.dataObj.id,
              },
            });
          }
          if (position_id == 6) {
            this.$router.push({
              path: "/jdyssh",
              query: {
                id: this.dataObj.id,
              },
            });
          }
          //-------------提交进度款凭证----------------
          if (position_id == 2) {
            this.$router.push({
              path: "/tjjdkpz",
              query: {
                id: this.dataObj.id,
              },
            });
          }
          //-------------进度款打款确认----------------
          if (position_id == 9) {
            this.$router.push({
              path: "/jdkqr",
              query: {
                id: this.dataObj.id,
              },
            });
          }
          //-------------施工记录----------------
          // if (position_id == 8) {
          //   this.$router.push({
          //     path: "/sgjl",
          //     query: {
          //       id: this.dataObj.id,
          //     },
          //   });
          // }
          break;
        case 1125: //确认增减项
          this.qrzjxVisible = true;
          break;
        case 1130: //出具结算单
          this.$router.push({
            path: "/cjjsd",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1135: //审核结算单
          this.$router.push({
            path: "/shjsd",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1138: //审核结算单
          this.$router.push({
            path: "/shjsd",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1140:
          //-------------提交尾款信息----------------
          this.$router.push({
            path: "/tjwkpz",
            query: {
              id: this.dataObj.id,
            },
          });
          //-------------回退至项目结算单----------------
          break;
        case 1145: //审核尾款信息
          this.$router.push({
            path: "/shwkxx",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1147: //确认尾款信息
          this.$router.push({
            path: "/qrwkxx",
            query: {
              id: this.dataObj.id,
            },
          });
          break;
        case 1500: //删除项目
          this.delProjectFunc(this.dataObj);
          break;
        default:
      }
    },
    typeOneFunc(state) {
      let position_id = getUserInfo().position_id;
      let dropdownMenuList = this.dropdownMenuList;
      let menuList = this.menuList;
      let index = menuList.findIndex((item) => {
        return (
          item.state == state && item.id == position_id && !item.node_status
        );
      });
      if (index == -1) return;
      if (position_id == menuList[index].id) {
        dropdownMenuList.push(menuList[index]);
      }
      this.dropdownMenuList = dropdownMenuList;
    },
    operationFunc() {
      let { position_id, userid } = getUserInfo();
      let dataObj = this.dataObj;
      let dropdownMenuList = [];
      let menuList = this.menuList;
      let index = 0;
      let projectNodesItem = this.projectNodesItem;
      switch (dataObj.status) {
        case 1000: //分配客户经理
          this.typeOneFunc(dataObj.status);
          break;
        case 1010: //选择勘场
          this.typeOneFunc(dataObj.status);
          break;
        case 1015: //上传设计图
          this.typeOneFunc(dataObj.status);
          break;
        case 1020: //提交勘场凭证
          this.typeOneFunc(dataObj.status);
          break;
        case 1025: //勘场费打款确认
          this.typeOneFunc(dataObj.status);
          break;
        case 1030: //分配勘场工程经理
          this.typeOneFunc(dataObj.status);
          break;
        case 1045: //分配勘场工程经理
          this.typeOneFunc(dataObj.status);
          break;
        case 1055: //上传勘场资料
          this.typeOneFunc(dataObj.status);
          break;
        case 1060: //上传设计图
          this.typeOneFunc(dataObj.status);
          break;
        case 1065: //申请报价
          this.typeOneFunc(dataObj.status);
          break;
        case 1070:
          //------------分配造价员-------------
          index = menuList.findIndex((item) => {
            return item.state == dataObj.status && item.label == "分配造价员";
          });
          if (
            index != -1 &&
            !dataObj.cost_estimator_id &&
            position_id == menuList[index].id
          ) {
            dropdownMenuList.push(menuList[index]);
          }
          //----------------分配施工工程经理--------------------
          index = menuList.findIndex((item) => {
            return (
              item.state == dataObj.status && item.label == "分配施工工程经理"
            );
          });
          if (
            index != -1 &&
            !dataObj.engineering_manager_id &&
            position_id == menuList[index].id
          ) {
            dropdownMenuList.push(menuList[index]);
          }
          this.dropdownMenuList = dropdownMenuList;
          break;
        case 1080:
          //-------------------分配施工工程经理--------------------
          index = menuList.findIndex((item) => {
            return (
              item.state == dataObj.status && item.label == "分配施工工程经理"
            );
          });
          if (
            index != -1 &&
            !dataObj.engineering_manager_id &&
            position_id == menuList[index].id
          ) {
            dropdownMenuList.push(menuList[index]);
          }
          this.dropdownMenuList = dropdownMenuList;
          //----------------出具造价单----------------
          this.typeOneFunc(dataObj.status);
          break;
        case 1090:
          //---------------申请报价--------------------
          index = menuList.findIndex((item) => {
            return (
              item.state == dataObj.status && item.label == "分配施工工程经理"
            );
          });
          if (
            index != -1 &&
            !dataObj.engineering_manager_id &&
            position_id == menuList[index].id
          ) {
            dropdownMenuList.push(menuList[index]);
          }
          // -----------------审核造价单-------------------
          index = menuList.findIndex((item) => {
            return item.state == dataObj.status && item.label == "审核造价单";
          });
          if (
            index != -1 &&
            dataObj.engineering_manager_id == userid &&
            position_id == menuList[index].id
          ) {
            dropdownMenuList.push(menuList[index]);
          }
          // -----------------拒绝接单-------------------
          index = menuList.findIndex((item) => {
            return item.state == dataObj.status && item.label == "拒绝接单";
          });
          if (
            index != -1 &&
            dataObj.engineering_manager_id == userid &&
            position_id == menuList[index].id
          ) {
            dropdownMenuList.push(menuList[index]);
          }
          this.dropdownMenuList = dropdownMenuList;
          break;
        case 1092: //审核造价单
          this.typeOneFunc(dataObj.status);
          break;
        case 1095: //对客报价
          this.typeOneFunc(dataObj.status);
          break;
        case 1100: //审核对客报价单
          this.typeOneFunc(dataObj.status);
          break;
        case 1102: //提交签订合约
          this.typeOneFunc(dataObj.status);
          break;
        case 1105: //提交预付款凭证
          this.typeOneFunc(dataObj.status);
          break;
        case 1110: //预付款打款确认
          this.typeOneFunc(dataObj.status);
          break;
        case 1115: //确认开始施工
          this.typeOneFunc(dataObj.status);
          break;
        case 1118:
          //-------------节点验收----------------
          index = menuList.findIndex((item) => {
            return item.state == dataObj.status && item.label == "节点验收";
          });
          if (
            index != -1 &&
            projectNodesItem.node_status == 1 &&
            dataObj.engineering_manager_id == userid &&
            position_id == menuList[index].id
          ) {
            dropdownMenuList.push(menuList[index]);
          }
          this.dropdownMenuList = dropdownMenuList;
          //-------------施工记录----------------
          if (position_id == 8) {
            this.typeOneFunc(dataObj.status);
          }
          break;
        case 1120:
          switch (projectNodesItem.node_status) {
            case 1:
              //-------------节点验收----------------
              index = menuList.findIndex((item) => {
                return item.state == dataObj.status && item.label == "节点验收";
              });
              if (
                index != -1 &&
                dataObj.engineering_manager_id == userid &&
                position_id == menuList[index].id
              ) {
                dropdownMenuList.push(menuList[index]);
              }
              break;
            case 2:
              //-------------节点验收审核----------------
              index = menuList.findIndex((item) => {
                return (
                  item.state == dataObj.status &&
                  item.label == "节点验收审核" &&
                  item.node_status == 2
                );
              });
              if (index != -1 && position_id == menuList[index].id) {
                dropdownMenuList.push(menuList[index]);
              }
              break;
            case 3:
              //-------------节点验收审核----------------
              index = menuList.findIndex((item) => {
                return (
                  item.state == dataObj.status &&
                  item.label == "节点验收审核" &&
                  item.node_status == 3
                );
              });
              if (index != -1 && position_id == menuList[index].id) {
                dropdownMenuList.push(menuList[index]);
              }
              break;
            case 4:
              //-------------提交进度款凭证----------------
              index = menuList.findIndex((item) => {
                return (
                  item.state == dataObj.status && item.label == "提交进度款凭证"
                );
              });
              if (index != -1 && position_id == menuList[index].id) {
                dropdownMenuList.push(menuList[index]);
              }
              break;
            case 5:
              //-------------进度款打款确认----------------
              index = menuList.findIndex((item) => {
                return (
                  item.state == dataObj.status && item.label == "进度款打款确认"
                );
              });
              if (index != -1 && position_id == menuList[index].id) {
                dropdownMenuList.push(menuList[index]);
              }
              break;
          }
          this.dropdownMenuList = dropdownMenuList;
          //-------------施工记录----------------
          if (position_id == 8) {
            this.typeOneFunc(dataObj.status);
          }
          break;
        case 1125: //确认增减项
          this.typeOneFunc(dataObj.status);
          break;
        case 1130: //出具结算单
          this.typeOneFunc(dataObj.status);
          break;
        case 1135: //审核结算单
          index = menuList.findIndex((item) => {
            return item.state == dataObj.status;
          });
          if (
            index != -1 &&
            dataObj.engineering_manager_id == userid &&
            position_id == menuList[index].id
          ) {
            dropdownMenuList.push(menuList[index]);
          }
          this.dropdownMenuList = dropdownMenuList;
          break;
        case 1138: //审核结算单
          this.typeOneFunc(dataObj.status);
          break;
        case 1140:
          //-------------提交尾款信息----------------
          index = menuList.findIndex((item) => {
            return item.state == dataObj.status && item.label == "提交尾款信息";
          });
          if (index != -1 && position_id == menuList[index].id) {
            dropdownMenuList.push(menuList[index]);
          }
          //-------------回退至项目结算单----------------
          index = menuList.findIndex((item) => {
            return (
              item.state == dataObj.status && item.label == "回退至项目结算单"
            );
          });
          if (index != -1 && position_id == menuList[index].id) {
            dropdownMenuList.push(menuList[index]);
          }
          this.dropdownMenuList = dropdownMenuList;
          break;
        case 1145: //审核尾款信息
          this.typeOneFunc(dataObj.status);
          break;
        case 1147: //确认尾款信息
          this.typeOneFunc(dataObj.status);
          break;
        case 1500: //删除项目
          this.typeOneFunc(dataObj.status);
          break;
        default:
      }
      console.log(this.dropdownMenuList,"--------------------------------")
    },
    // 历史数据
    getProjectLogNew(status) {
      projectApi
        .getProjectLogNew({
          project_id: this.dataObj.id,
          status,
        })
        .then((res) => {
          console.log(res, "历史数据");
        });
    },
    // 统一弹窗请求完成回调
    onSuccess() {
      this.fpkhjlVisible = false; //分配客户经理
      this.scsjtVisible = false; //上传设计图
      this.kcxxVisible = false; //提交勘场凭证
      this.kcfdkqrVisible = false; //勘场费打款确认
      this.dkrzVisible = false; //对客日志
      this.fpgcjVisible = false; //分配工程经理
      this.gcjljjjdVisible = false; //工程经理拒绝接单
      this.tjkcxxVisible = false; //提交勘场报告
      this.shkczlVisible = false; //上传勘场资料
      this.sqbjVisible = false; //申请报价
      this.fpzjyVisible = false; //分配造价员
      this.cjzjdVisible = false; //出具造价单
      this.shbjdVisible = false; //审核造价单
      this.dkbjVisible = false; //对客报价
      this.shdkbjdVisible = false; //审核对客报价单
      this.tjqdhtVisible = false; //提交签订合同
      this.tjyfkpzVisible = false; //提交预付款凭证
      this.yfkdkqrVisible = false; //预付款凭证确认
      this.qrkssgVisible = false; //确认开始施工
      this.jdysVisible = false; //节点验收
      this.jdysshVisible = false; //节点验收审核
      this.tjjdkpzVisible = false; //提交进度款凭证
      this.jdkqrVisible = false; //进度款打款确认
      this.qrzjxVisible = false; //确认增减项
      this.xmqxVisible = false; //项目取消
      this.sgjlVisible = false; //提交施工日志
      this.cjjsdVisible = false; //出具结算单
      this.shjsdVisible = false; //审核结算单
      this.tjwkpzVisible = false; //提交尾款凭证
      this.shwkxxVisible = false; //审核尾款信息
      this.qrwkxxVisible = false; //确认尾款
      this.addDialogVisible = false; //完善项目

      this.cancelFunc();
      this.$emit("onSuccess", true);
    },
    // 删除项目
    delProjectFunc(row) {
      console.log(row);
      this.$confirm("此操作将永久删除该项目, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.delProject(row.id);
        })
        .catch(() => { });
    },
    // 删除项目请求
    delProject(project_id) {
      projectApi
        .delProject({ project_id, remark: "" })
        .then((res) => {
          console.log(res, "删除项目");
          if (res.code == 200) {
            this.$message.success("删除成功");
            this.getProjectList();
          } else {
            this.$message.warning(res.message);
          }
        })
        .catch((err) => {
          this.$message.warning(err.message);
        });
    },
    // 详情engineering_manager_id
    getProjectDetails() {
      let menuList = this.menuList;
      return new Promise((resolve, reject) => {
        projectApi
          .getProjectDetails({
            project_id: this.dataObj.id,
          })
          .then((res) => {
            this.pageLoading = false;
            console.log(res, "项目详情", res.data.status, res.data.id);
            if (res.code == 200) {
              // 判断当前需要验收的节点
              //     node_status: 1,
              // engineering_manager_id: "",
              let project_nodes = "";
              if (res.data.status == "1120" || res.data.status == "1118") {
                for (let i = 0; i < res.data.project_nodes.length; i++) {
                  if (res.data.project_nodes[i].node_status != 6) {
                    project_nodes = res.data.project_nodes[i];
                    break;
                  }
                }
                this.projectNodesItem = project_nodes;
                console.log(
                  project_nodes,
                  "当前需执行节点",
                  project_nodes.node_status
                );
                menuList.forEach((item) => {
                  if (
                    (item.state == 118 || item.state == 1120) &&
                    item.id == 7
                  ) {
                    item.engineering_manager_id =
                      this.dataObj.engineering_manager_id;
                  }
                });
              }
              this.menuList = menuList;
              this.$nextTick(() => {
                this.operationFunc();
              });
            } else {
              this.$message.warning(res.message);
            }
          })
          .catch((err) => {
            this.$message.warning(err.message);
          });
      });
    },
    // 施工记录
    sgjlFunc() {
      this.$router.push({
        path: "/sgjl",
        query: {
          id: this.dataObj.id,
        },
      });
    },
    // 回退至报价单、结算单
    xmhtFunc(type) {
      this.$prompt("请输入回退理由", "提示", {
        confirmButtonText: "确定回退",
        cancelButtonText: "取消",
        inputPattern: /^.+$/,
        inputErrorMessage: "理由不能为空",
      })
        .then(({ value }) => {
          if (type == "bj") {
            this.quotationReviewRejected({
              remark: value,
              status: 1080,
              project_id: this.dataObj.id,
            });
          } else {
            // 1130
            this.settlementStatementRejected({
              remark: value,
              status: 1130,
              project_id: this.dataObj.id,
            });
          }
        })
        .catch(() => { });
    },
    // 回退结算单
    settlementStatementRejected(data) {
      projectApi.settlementStatementRejected(data).then((res) => {
        console.log(res, "回退至结算单");
        if (res.code == 200) {
          this.onSuccess();
        }
        this.$message({
          type: res.code == 200 ? "success" : "warning",
          message: res.code == 200 ? "处理成功" : res.message,
        });
      });
    },
    // 回退造价单
    quotationReviewRejected(data) {
      projectApi.quotationReviewRejected(data).then((res) => {
        console.log(res, "回退至报价单");
        if (res.code == 200) {
          this.onSuccess();
        }
        this.$message({
          type: res.code == 200 ? "success" : "warning",
          message: res.code == 200 ? "处理成功" : res.message,
        });
      });
    },
    // 完善项目
    editProjectFunc() {
      let dataObj = this.dataObj;
      this.addFormInline = {
        designer_name: dataObj.designer_name,
        project_id: dataObj.id,
        project_type: dataObj.project_type,
        project_name: dataObj.project_name,
        project_city: [dataObj.province_id, dataObj.city_id, dataObj.county_id],
        address: dataObj.address,
        user_id: dataObj.user_id,
        channel_manager_id: dataObj.channel_manager_id,
        brand_id: dataObj.brand_id,
        brand_name: dataObj.brand_name,
        survey_site: dataObj.survey_site,
        designer_id: dataObj.designer_id,
        template_id: dataObj.template_id,
        template_name: dataObj.template_name,
        // engineeringSupervision_id: '',
        survey_date: dataObj.survey_date,
        channel_manager_id: dataObj.channel_manager_id,
        channel_manager_name: dataObj.channel_manager_name,
        receiving_account_id: dataObj.receiving_account_id,
      };
      this.surveySiteDisabled = dataObj.status >= 1025;
      this.addDialogVisible = true;
    },
    // 关闭完善项目
    cancelFunc() {
      this.addFormInline = {
        designer_name: "",
        project_id: "",
        channel_manager_id: "",
        channel_manager_name: "",
        project_type: "",
        project_name: "",
        project_city: [],
        address: "",
        user_id: "",
        channel_manager_id: "",
        brand_id: "",
        survey_site: "",
        designer_id: "",
        template_id: "",
        // engineeringSupervision_id: '',
        survey_date: "",
      };
      this.$nextTick(() => {
        this.addDialogVisible = false;
      });
    },
  },
};
</script>
<style lang="scss" scoped>
// @import "./index.scss";</style>